import 'package:client_ui/util/GlobalData.dart';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';

import '../util/GenerateUtil.dart';

class UserComponent extends StatelessWidget {
  final String title;
  final String avatarUrl;

  const UserComponent(
      {super.key, required this.title, required this.avatarUrl});

  @override
  Widget build(BuildContext context) {
    return GestureDetector(
      child: Container(
          width: 50,
          height: 50,
          margin: const EdgeInsets.all(2),
          // padding: const EdgeInsets.all(2),
          decoration: BoxDecoration(
              color: Colors.blue, borderRadius: BorderRadius.circular(8)),
          child: GenerateUtil.generateAvatar(avatarUrl, 50, 50)
          // Text(
          //   title,
          //   style: TextStyle(color: Colors.white, fontSize: 18),
          // ),
          ),
      onTap: () {
        Provider.of<GlobalData>(context, listen: false).setName(title);
      },
    );
  }
}
